-
-
Notifications
You must be signed in to change notification settings - Fork 247
No special font-locking for mixedCase, CamelCase #462
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Perhaps this is the better approach indeed. We'll lose the special font-locking for interop methods, but it didn't seem particularly important to begin with. |
test/clojure-mode-font-lock-test.el
Outdated
@@ -161,7 +161,7 @@ POS." | |||
(should (eq (clojure-test-face-at 2 3) 'font-lock-type-face)) | |||
(should (eq (clojure-test-face-at 5 14) 'font-lock-type-face)))) | |||
|
|||
(ert-deftest clojure-mode-syntax-table/namespace () | |||
(ert-deftest clojure-mode-syntax-table/segmented-symbol () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to me that those tests should actually fail now - from what I gather by your changes we aim to font-lock as ns-es only ns symbols that are in the ns
macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this is the better approach indeed.
Glad to hear it :)
It seems to me that those tests should actually fail now - from what I gather by your changes we aim to font-lock as ns-es only ns symbols that are in the ns macro.
Yea, I'll work on it. (I just wanted to hear your general opinion in the first place.) I'll tell you when have something to show.
I made a good progress. Please have a look. Thx. |
clojure-mode.el
Outdated
;; foo.bar.baz | ||
("\\<^?\\([a-z][a-z0-9_-]+\\.\\([a-z][a-z0-9_-]*\\.?\\)+\\)" 1 font-lock-type-face) | ||
;; (ns namespace) - special handling for single segment namespaces | ||
|
||
(,(concat "(\\<ns\\>[ \r\n\t]*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some comment for each regular expression, otherwise it's hard to understand their purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.
clojure-mode.el
Outdated
"\\(" clojure--sym-regexp "\\)") | ||
(1 font-lock-type-face)) | ||
|
||
(,(concat "\\(:\\)\\(" clojure--sym-regexp "\\)\\(/\\)\\(" clojure--sym-regexp "\\)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm quite puzzled by this regexp.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added.
clojure-mode.el
Outdated
(2 'clojure-keyword-face)) | ||
|
||
;; type-hints | ||
(,(concat "\\(#^\\)\\(" clojure--sym-regexp "\\)\\(/\\)\\(" clojure--sym-regexp "\\)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the first is some qualified symbol, but certainly some examples would make the intent clearer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the test.clj
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant there should be some examples here as well, so it's easier to map those regular expressions to what they are supposed to font-lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant there should be some examples here
(simple) examples added. More elaborate examples are in the test.clj
I see 3 tests are failing on Travis. This also needs a changelog entry. |
test.clj
Outdated
[veryCom|pLex.stu-ff])) | ||
|
||
;; TODO the face of 'fn' is 't'. Where is it defined? | ||
(fn foo [x] x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fn
is in the list of special forms, so it should be font-locked as one. I can't imagine what can cause the problem you've mentioned. At least I don't see anything obvious in your changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to have a look at it. Give me some time please.
("\\<^?\\(:\\(\\sw\\|\\s_\\)+\\(\\>\\|\\_>\\)\\)" 1 'clojure-keyword-face append) | ||
;; Java interop highlighting | ||
;; CONST SOME_CONST (optionally prefixed by /) | ||
("\\(?:\\<\\|/\\)\\([A-Z]+\\|\\([A-Z]+_[A-Z1-9_]+\\)\\)\\>" 1 font-lock-constant-face) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I guess no special font-locking for SCREAMING_UPPER_CASE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, no special font-locking for SCREAMING_UPPER_CASE at the moment. But feel free to change or propose something else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just mentioning it. I don't feel strongly about this.
@Bost How is all of this shaping up? |
I'm not sure how to document it. I (partially) fixed one of them, so:
In general, I've been using this branch for 2+ weeks w/o any problem. I think the RC1 is done. |
... I just stumbled upon an interesting article about https://en.wikipedia.org/wiki/Hibernation, hmm. |
CHANGELOG.md
Outdated
@@ -21,6 +21,7 @@ | |||
* [#429](https://github.com/clojure-emacs/clojure-mode/issues/429): Fix a bug causing last occurrence of expression sometimes is not replaced when using `move-to-let`. | |||
* [#423](https://github.com/clojure-emacs/clojure-mode/issues/423): Make `clojure-match-next-def` more robust against zero-arity def-like forms. | |||
* [#451](https://github.com/clojure-emacs/clojure-mode/issues/451): Make project root directory calculation customized by `clojure-project-root-function`. | |||
* Numerous font-locking fixes and improvements |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
List here the biggest user-visible changes explicitly and I guess we can merge this.
Does this work for you? I'm assuming the failure must be related to changing the ns regexp or something.
Define partially. :-) As for documenting it - I'd stick to high-level. Something like:
You can also post here some screenshot of before and after for people who'll stumble upon this ticket. And sorry about the slow responses, but I've been crazy busy lately and I spend my little spare time focusing on some long overdue CIDER improvements. |
Yeah, the ns part certainly looks good. I was also referring to the other things affected by this - e.g. constants and interop methods. Anyways, update the changelog to be more granular and I guess we can merge this and gather more feedback for the users. |
@Bost ping :-) |
* s/clojure-interop-method-face/font-lock-type-face * keyword font-locking * visual examples w/ ert tests * fix failing ert tests
I've done it. See the CHANGELOG.md
Oh BTW I was able to fix the failing emacs-25.1-travis and emacs-25.2-travis builds. The failing
that was IMO faulty. The '#_' char sequence wasn't matched by any font-locking regex so then its face should be Another thing: I wonder how was my predecessor able to pass the travis tests without ant long-line warning? See https://travis-ci.org/clojure-emacs/clojure-mode/jobs/352241172 @alexander-yakushev ? |
Just another odd Travis problem I guess. Thanks for tackling this! |
This shaved the highlighting of type hints. I find it much harder to read inter-op code now because types are easily confused with arguments. Any objection of putting |
Actually the PR has provisioned type face for hints, but they don't work for me starting with this PR. |
@vspinu I can confirm this. I guess you can file another ticket so we won't forget to fix this. |
Could you show some screenshots please? Or even better add a new test case. I haven't done much SW development in the last X weeks. I need to update myself at first. Thanks. |
The type hints were fixed in dd8a193. |
This is an alternative approach to my PR regarding fix-namespace-font-locking.
I find out the clojure-interop-method-face is not really needed for mixedCase, CamelCase... and it simplifies the regexp a lot. What do you think about that?
In case you think the mixedCase, CamelCase are needed indeed, then I'd build-up/rework their pattern matching based on this simplification.